package com.shiguiwu.springmybatis.spring.imports.demo;

import com.shiguiwu.springmybatis.spring.imports.demo.proxy.CostTimeProxy;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @description: bean创建的时候拦截
 * @author: stone
 * @date: Created by 2021/9/29 17:26
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.imports.demo
 */
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean.getClass().getName().toLowerCase().contains("service")) {
            return CostTimeProxy.createProxy(bean);
        }
        return bean;
    }

}
